package com.bee.health;
 

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.bee.health.view.EasyPickerView;
import com.bee.health.view.MiuiWeatherView;
import com.bee.health.view.MyRoundProcess;
import com.bee.health.view.WeatherBean;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
 
import android.view.View;
import android.widget.TextView;
 

public class SHomeActivity extends Activity {

	private MiuiWeatherView weatherView;
    private EasyPickerView epvH;
    private EasyPickerView epvX;
    private EasyPickerView epvS;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_shome);
		//滚动选择自定义view
		epvH = (EasyPickerView) findViewById(R.id.epvH);
		epvX = (EasyPickerView) findViewById(R.id.epvX);
		epvS = (EasyPickerView) findViewById(R.id.epvS);
		 final ArrayList<String> hDataList = new ArrayList<String>();
		 final ArrayList<String> xDataList = new ArrayList<String>();
		 final ArrayList<String> SDataList = new ArrayList<String>();
		
		  for (int i = 120; i < 220; i=i+5)
			  hDataList.add("" + i);
		  
		  xDataList.add("步行");
	      xDataList.add("慢跑");
	      SDataList.add("男");
	      SDataList.add("女");
	    epvH.setDataList(hDataList);
	    epvX.setDataList(xDataList);
	    epvS.setDataList(SDataList);
	    epvS.setOnScrollChangedListener(new EasyPickerView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(int curIndex) {
                //这里是选项改变的回调
            }

            @Override
            public void onScrollFinished(int curIndex) {
            	//这里是选项停止的回调
            }
        });
	    epvX.setOnScrollChangedListener(new EasyPickerView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(int curIndex) {
            	//这里是选项改变的回调
            }

            @Override
            public void onScrollFinished(int curIndex) {
            	//这里是选项停止的回调
            }
        });
	    epvH.setOnScrollChangedListener(new EasyPickerView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(int curIndex) {
            	//这里是选项改变的回调
            }

            @Override
            public void onScrollFinished(int curIndex) {
            	//这里是选项停止的回调
            }
        });
//	    天气自定义view
	    weatherView = (MiuiWeatherView) findViewById(R.id.weather);
	    List<WeatherBean> data = new ArrayList<WeatherBean>();
	    Random random = new Random();
        String[] weathers = WeatherBean.getAllWeathers();
        int count = 0;
        for (int i = 0; i < 8; i++) {
            int a = random.nextInt(6);//随机天气
            int b = 1+random.nextInt(4);//随机连续天气数
            for(int j = 0; j < b; j++){
                count ++;
                int c = random.nextInt(5); //随机温度
                WeatherBean bean = new WeatherBean(weathers[a],20+c,count+":00");
                data.add(bean);
            }
        }
        data.get(2).temperatureStr = "日出";
        
        data.get(4).temperatureStr = "日落";
     

        WeatherBean b1 = new WeatherBean(weathers[0],20,"05:00");
        WeatherBean b2 = new WeatherBean(weathers[1],22,"日出","05:30");
        WeatherBean b3 = new WeatherBean(weathers[2],21,"06:00");
        WeatherBean b4 = new WeatherBean(weathers[2],22,"07:00");
        WeatherBean b5 = new WeatherBean(weathers[2],23,"08:00");
        WeatherBean b6 = new WeatherBean(weathers[3],20,"09:00");
        data.add(b1);
        data.add(b2);
        data.add(b3);
        data.add(b4);
        data.add(b5);
        data.add(b6);

        weatherView.setData(data);
//圆形进度条自定义view	    
	    //这里可以定义进度条比例
	    MyRoundProcess myRoundProcess1 = (MyRoundProcess) findViewById(R.id.my_round_process1);
	    myRoundProcess1.runAnimate(60);
	    MyRoundProcess myRoundProcess2 = (MyRoundProcess) findViewById(R.id.my_round_process2);
	    myRoundProcess2.runAnimate(50);
		findViewById(R.id.safeOut).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,StepestimateActivity.class);
				startActivity(intent);
			}
		});
		
//		TextView text1 = (TextView) findViewById(R.id.text1);
//		text1.setText("今日运动量");
		
		findViewById(R.id.callmsgsafeOut).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,StepCountActivity.class);
				startActivity(intent);
			}
		});
		findViewById(R.id.appOut).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,DistanceActivity.class);
				startActivity(intent);
			}
		});
		
		findViewById(R.id.sysoptimizeOut).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,SportplanActivity.class);
				startActivity(intent);
			}
		});
		
		findViewById(R.id.settingsOut).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,MotiontrailActivity.class);
				startActivity(intent);
			}
		});
         findViewById(R.id.women).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent;
				intent=new Intent(SHomeActivity.this,AboutUs.class);
				startActivity(intent);
			}
		});
		
	}
 
}
